﻿@using Vcare.Properties
@model Vcare.Models.UserInfo

@{
    ViewBag.Title = "Edit";
}

<h2>Edit User</h2>
<div class="spacer"></div>
@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>UserInfo</legend>

        @Html.HiddenFor(model => model.UserInfoID)
        @Html.HiddenFor(model => model.UserID)
        @Html.HiddenFor(model => model.User.UserId)
        @Html.HiddenFor(model => model.User.ApplicationId)
        @Html.HiddenFor(model => model.User.IsAnonymous)

        <div class="editor-label">
            @Html.LabelFor(model => model.User.UserName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.User.UserName)
            @Html.ValidationMessageFor(model => model.User.UserName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Firstname)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Firstname)
            @Html.ValidationMessageFor(model => model.Firstname)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Surname)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Surname)
            @Html.ValidationMessageFor(model => model.Surname)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.CallCentreID)
        </div>
        <div class="editor-field">
        @if (this.User.IsInRole(ApplicationRoles.CCAdministrator))
	    {
		<label style="font-family: Arial, Helvetica, sans-serif; color: #800000; font-weight: bold; font-size: large;">@Model.CallCentre.CallCentre</label> 
	    }
        else
        {
            @Html.DropDownList("CallCentreID", (SelectList)ViewBag.CallCentreID
            ,new 
                {
                 @class="chosen",
                 style = "width: 300px;"
                }
                )
        }
            @Html.ValidationMessageFor(model => model.CallCentreID)
        </div>
        <div class="spacer"></div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Notes)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Notes, new { @class="largenotes" })
            @Html.ValidationMessageFor(model => model.Notes)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.AuthorityID, "Authority")
        </div>
        <div class="editor-field">
                @Html.DropDownList("AuthorityID", (SelectList)ViewBag.AuthorityID,
                new
                {
                    @class = "chosen",
                    style = "width: 300px;"
                }
                )
            @Html.ValidationMessageFor(model => model.AuthorityID)
        </div>
        <input type="hidden" name="oldAuthorityID" id="oldAuthorityID" value="@(Model.AuthorityID)" />
        <div class="spacer"></div>
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}
<div class="spacer"></div>

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

<script type="text/javascript">
    $(document).ready(function () {

        $("#CallCentreID").val("@(Model.CallCentreID)");
        $("#AuthorityID").val("@(Model.AuthorityID)");

        $(".chosen").chosen();

    });
</script>